import {Injectable} from '@angular/core';
import Dexie, {Table} from 'dexie';

@Injectable({providedIn: 'root'})
export class DBService {

    constructor() {}
    public db = new Dexie('xyqlxpy');
    connect() {
        this.db.version(1).stores({info: "&key,value", courseProgress: "&id,state,page,task", code: "[course+page],code,input", course: "&id,name,data"});
        this.db.open().catch((error) => {
            console.log("Errod during connecting to database : " + error);
        });
    }
    table(name : string): Table {
        return(this.db as any)[name];
    }

}
